
#include "iostream"
#include "vector"
#include "unordered_map"
#include "algorithm"

    bool cmp(std::pair<int, int> &p1, std::pair<int, int> &p2) {
    if (p1.second == p2.second) {
        return p1.first < p2.first;
    }

    return p1.second < p2.second;
}

struct Sol {
    std::vector<char> two_sqr_num;
    std::vector<std::pair<int, int>> oks;

    void run(int n, int m) {
        two_sqr_num.resize(m * m * 2+1);
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= m; j++) {
                two_sqr_num[i * i + j * j] = 1;
            }
        }
        //a起始位置
        for (int a = 0; a <= m * m * 2; a++) {
            //b间距
            for (int b = 1; b <= (m * m * 2-a) / (n-1); b++) {
                bool ok = true;
                for (int i = 0; i < n; i++) {
                    if (a + b * i >= two_sqr_num.size() ||
                        two_sqr_num[a + b * i] == 0
                            ) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    oks.emplace_back(a, b);
                }
            }
        }
        std::sort(oks.begin(),oks.end(), cmp);
        for(auto &p:oks){
            printf("%d %d\n",p.first,p.second);
        }
        if(oks.size()==0){
            printf("NONE\n");
        }
    }
};

int main() {
    int n, m;
    while (std::cin >> n >> m) {
        Sol().run(n, m);
    }
//    while(1){}
    return 0;
}